"""It receives image data as a string and returns into array
    with each array value of length as defined."""
def getImageDataInArray(self, imData):
    data = imData
    arrayData = []
    if '\r\n' in data:
        data = data.replace('\r\n', '@@@@@')
    chunkLen = 14000
    chunks = len(data)/chunkLen
    # round up the value of the chunks to define the size of array
    if((len(data) % chunkLen) is not 0):
        chunks = int(chunks + 1)
    # populate chunks of image data into array
    for i in range(0, chunks):
        if i is not chunks-1:
            arrayData.append("data="+data[(chunkLen*i):(chunkLen*(i+1))])
        else:
            arrayData.append("data="+data[(chunkLen*i):(chunkLen*(i+1))]+"end of data")
    return arrayData

""" It combines all the chunks of image data received from server
    and return an image in string """
def getImageInString(self, imData):
    imInString = ''
    imInString = imData.replace('data=', '')
    if imData.endswith('end of data'):
        self.imageData = self.imageData + imInString.replace('end of data', '')
        if '@@@@@' in self.imageData:
            self.imageData = self.imageData.replace('@@@@@', '\r\n')
    else:
        self.imageData = self.imageData + imInString
        
    return self.imageData